package StudyCode.summary.myfile;

import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GetLastTokenizeFilePath {

	public static void main(String[] args) {
		System.out.println(lastPathToken("/home/docs/status.txt"));
	}

	private static String lastPathToken(String path) {
		ArrayList<String> tokens = tokenizePath(path);
		return tokens.get(tokens.size() - 1);
	}


	private static ArrayList<String> tokenizePath(String path) {
		path = path.replace('\\', '/');
		StringTokenizer tokenizer = new StringTokenizer(path, "/");
		ArrayList<String> tokens = new ArrayList<>();
		while (tokenizer.hasMoreTokens()) {
			tokens.add(tokenizer.nextToken());
		}
		return tokens;
	}

}
